<?php
namespace app\supplier\controller;
use think\Controller;
use app\erp\model\Attrdb;
class Attr extends Base{
    public $post;
    public $db;
    public function _initialize(){
        parent::_initialize();
        $request = request();
        $param = $request->param();
        $this->post = $param;
        $attrdb = new Attrdb();
        $attrdb->param = $this->post;
        $this->db = $attrdb;
    }
    // 获取列表
    public function ajaxAttr(){
        $return = $this->db->ajaxSelect($this->post['category_sign']);
        $this->layuiReturn($return['data'], $return['count']);
    }
    // 渲染模板
    public function tplForm($category_sign){
        $this->assign('attr_id','');
        $this->assign('category_sign',$category_sign);
        return $this->fetch();
    }
    public function ajaxList(){
        $this->db->param = $this->post;
        $return = $this->db->ajaxSelect();
        $this->layuiReturn($return['data'], $return['count']);
    }
    // 保存数据
    public function saveData(){
        $return = $this->db->ajaxSave();
        if ($return != 'success') {
            $this->layuiReturn($return, 0, $return, - 1);
        } else {
            $this->layuiReturn($return,'','保存成功');
        }
    }
    /**
     *
     * @todo 软删除
     */
    public function ajaxDelete()
    {
        $this->db->param = $this->post;
        $this->db->ajaxDelete();
        $this->layuiReturn('删除成功', 0);
    }
}